package com.gitee.mp.core.interceptor;

import com.gitee.mp.core.connector.MilvusConnector;
import com.gitee.mp.core.mapper.MilvusMapperHandler;
import com.gitee.mp.domain.definition.CollectionDefinition;
import lombok.Data;
import lombok.experimental.Accessors;

import java.lang.reflect.Method;
import java.util.List;

/**
 * @author hongda.li
 */
@Data
@Accessors(chain = true)
public class InterceptorContext {

    private final Class<?> mapper;

    private final Class<?> entity;

    private final MilvusConnector connector;

    private final CollectionDefinition definition;

    private Method method;

    private Object result;

    private List<Object> arguments;

    public static InterceptorContext fromHandler(MilvusMapperHandler handler) {
        return new InterceptorContext(handler.getMapper(),
                handler.getEntity(),
                handler.getConnector(),
                handler.getDefinition());
    }
}
